define(['app'], function(app) {
	'use strict';

	// 实例化方法
	var factory = function(Http) {
		function get_data_list(result) {
			if(!false) {
				result = '{"success": true,"msg": "","result": {"doing": [' +
					'{"act_id": "001","name": "促销","start_time": "2017/01/01 09:00:00","end_time": "2017/02/01 09:00:00","image": {"id": "001","image": "img/purchaseNow1.png"}},' +
					'{"act_id": "002","name": "促销","start_time": "2017/01/01 09:00:00","end_time": "2017/02/01 09:00:00","image": {"id": "001","image": "img/purchaseNow1.png"}}],"pending": [' +
					'{"act_id": "003","name": "促销","start_time": "2017/01/01 09:00:00","end_time": "2017/02/01 09:00:00","image": {"id": "003","image": "img/purchaseNow1.png"}},' +
					'{"act_id": "004","name": "促销","start_time": "2017/01/01 09:00:00","end_time": "2017/02/01 09:00:00","image": {"id": "004","image": "img/purchaseNow1.png"}}],"ended": [' +
					'{"act_id": "005","name": "促销","start_time": "2016/01/01 09:00:00","end_time": "2017/02/01 09:00:00","image": {"id": "005","image": "img/purchaseNow1.png"}},' +
					'{"act_id": "006","name": "促销","start_time": "2016/01/01 09:00:00","end_time": "2017/02/01 09:00:00","image": {"id": "006","image": "img/purchaseNow1.png"}}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else
				return result;
		}
		
		return {
			get_list: function(from_type,nPage, callback,calldone) {
				//post请求
				Http.post({
					method: 'marketing.panicbuy.getlist',
					from_type: from_type,
					pagelimit: 6,
					nPage: nPage
				}, function(result) {
					//函数回调
					if(callback)
						callback(get_data_list(result).result);
				},function(e){
					
				},function(){
					if(calldone)
						calldone();
				});

			}
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Purchase", factory);
});